home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / winlib.lzh / WINLIB / ALERT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-17  |  9.4 KB  |  155 lines

  1. /********************************************************************
  2.  *                                                                    *
  3.  *    Custom Alert Box handler                                        *
  4.  *                                                                    *
  5.  *    Copyright (c) Clever Bits and Bitgate Software 1993 - 1994        *
  6.  *    All Rights Reserved.                                            *
  7.  *                                                                    *
  8.  *    These routines are for handling custom alert box routines in    *
  9.  *    which you can move alerts, click on them, and get information    *
  10.  *    from them.  That's what an ALERT is for!                        *
  11.  *                                                                    *
  12.  ********************************************************************
  13.  *                                                                    *
  14.  *    To add:                                                            *
  15.  *    """""""                                                            *
  16.  *    Calling like form_alert (string method)                            *
  17.  *    Windowize alert box (with its own routine to handle top window) *
  18.  *                                                                    *
  19.  ********************************************************************
  20.  *                                                                    *
  21.  *    Update log:                                                        *
  22.  *    [3.12.93 - 5.3.94] Ken Hollis                                    *
  23.  *        WFormCustAlert    - fixed some incoherence with dialog box    *
  24.  *                        - fixed up the resource file (redesigned)    *
  25.  *                        - fixed up and added fix_objects() to start    *
  26.  *                        - added fix_object for 3D object stuff        *
  27.  *                        - fixed up resource internally to look        *
  28.  *                            better                                    *
  29.  *        WInitAlert        - added for initialization                    *
  30.  *        (global)        - type casted for compatibility                *
  31.  *                        - optimized some places where needed        *
  32.  *                                                                    *
  33.  ********************************************************************/
  34.  
  35. #include <stdio.h>
  36. #include <string.h>
  37.  
  38. #include "winlib.h"        /* WinLIB header file */
  39. #include "nkcc.h"        /* Normalized Keycodes header file */
  40.  
  41. #ifdef __TURBOC__
  42. #pragma warn -pia
  43. #endif
  44.  
  45. #ifndef __ALERT__
  46. #define __ALERT__
  47. #endif
  48.  
  49. static char p_to_nul[1] = "";
  50.  
  51. #include "ALEXCLAM.ICN"    /* GEM standard exclamation point */
  52. #include "ALQUEST.ICN"    /* GEM standard question mark */
  53. #include "ALSTOP.ICN"    /* GEM standard stop sign */
  54. #include "DEXCLAM.ICN"    /* rs_object Disk exclamation point */
  55. #include "DQUEST.ICN"    /* rs_object Disk question mark */
  56. #include "D_X.ICN"        /* rs_object Disk with an "X" */
  57.  
  58. int image_data[128] = {
  59.     0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
  60.     0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
  61.     0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
  62.     0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
  63.     0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
  64.     0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
  65.     0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
  66.     0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0};
  67.  
  68. TEDINFO rs_tedinfo[] = {
  69.   {" Alert box header ", p_to_nul, p_to_nul,
  70.      3,   0,   2, 4513,   0,  -1,  19,   1},
  71.   {"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", p_to_nul, p_to_nul,
  72.      3,   6,   0, 4480,   0,  -1,  31,   1},
  73.   {"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", p_to_nul, p_to_nul,
  74.      3,   6,   0, 4480,   0,  -1,  31,   1},
  75.   {"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", p_to_nul, p_to_nul,
  76.      3,   6,   0, 4480,   0,  -1,  31,   1},
  77.   {"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", p_to_nul, p_to_nul,
  78.      3,   6,   0, 4480,   0,  -1,  31,   1},
  79.   {"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", p_to_nul, p_to_nul,
  80.      3,   6,   0, 4480,   0,  -1,  31,   1},
  81.   {"Button", p_to_nul, p_to_nul,
  82.      3,   0,   2, 4480,   0,  -2,   7,   1},
  83.   {"Button", p_to_nul, p_to_nul,
  84.      3,   0,   2, 4480,   0,  -3,   7,   1},
  85.   {"Button", p_to_nul, p_to_nul,
  86.      3,   0,   2, 4480,   0,  -2,   7,   1}
  87. };
  88.  
  89. int imask000[] = {
  90.   0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  91.   0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  92.   0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  93.   0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  94.   0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  95.   0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  96.   0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  97.   0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
  98. };
  99.  
  100. int idata000[] = {
  101.    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  102.    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  103.    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  104.    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  105.    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  106.    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  107.    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  108.    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
  109. };
  110.  
  111. ICONBLK rs_iconblk[] = {
  112.   {imask000, idata000, " ",
  113.    0x1000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0020,
  114.    0x0020, 0x000d, 0x000e, 0x0006, 0x0008}
  115. };
  116.  
  117. BITBLK rs_bitblk[] = { 0L };
  118.  
  119. OBJECT rs_object[] = {
  120.   /* Tree #0*/
  121.   {  -1,   1,   1,G_BOX,NONE,NORMAL, (long)(0x00001173L),   0,   0, 294, 267},
  122.   {   0,   2,  12,G_BOX,FL3DBAK,DRAW3D, (long)(0x00ff1100L), 256, 256,1829,1802},
  123.   {   3,  -1,  -1,0x1116,(FL3DACT|TOUCHEXIT),DRAW3D, (long)(&rs_tedinfo[0]),   0,   0,1829, 257},
  124.   {   9,   4,   8,0x141A,FL3DACT,(WHITEBACK|DRAW3D), (long)(p_to_nul),1797,1537, 799, 774},
  125.   {   5,  -1,  -1,G_TEXT,NONE,NORMAL, (long)(&rs_tedinfo[1]),1536,1536,  31,   1},
  126.   {   6,  -1,  -1,G_TEXT,NONE,NORMAL, (long)(&rs_tedinfo[2]),1536,1537,  31,   1},
  127.   {   7,  -1,  -1,G_TEXT,NONE,NORMAL, (long)(&rs_tedinfo[3]),1536,1538,  31,   1},
  128.   {   8,  -1,  -1,G_TEXT,NONE,NORMAL, (long)(&rs_tedinfo[4]),1536,1539,  31,   1},
  129.   {   3,  -1,  -1,G_TEXT,NONE,NORMAL, (long)(&rs_tedinfo[5]),1536,1540,  31,   1},
  130.   {  10,  -1,  -1,G_ICON,NONE,NORMAL, (long)(&rs_iconblk[0]),   1,1794,   4,   4},
  131.   {  11,  -1,  -1,G_BOXTEXT,(SELECTABLE|EXIT|FL3DACT),DRAW3D, (long)(&rs_tedinfo[6]),1792,1800, 266, 769},
  132.   {  12,  -1,  -1,G_BOXTEXT,(SELECTABLE|EXIT|DEFAULT|FL3DACT),DRAW3D, (long)(&rs_tedinfo[7]), 782,1800, 266, 769},
  133.   {   1,  -1,  -1,G_BOXTEXT,(SELECTABLE|EXIT|LASTOB|FL3DACT),DRAW3D, (long)(&rs_tedinfo[8]),1818,1800, 266, 769}
  134. };
  135.  
  136. OBJECT *MYALERT = rs_object;
  137.  
  138. ICONBLK    ICONZ[] =
  139. {
  140.     {(int *)(alexclam), (int *)(image_data), (char *)(p_to_nul), 0x0100, 0x0000,
  141.      0x0000, 0x0000, 0x0000, 0x0020,
  142.      0x0020, 0x000C, 0x0010, 0x0000, 0x0000},
  143.     {(int *)(alquest), (int *)(image_data), (char *)(p_to_nul), 0x0100, 0x0000,
  144.      0x0000, 0x0000, 0x0000, 0x0020,
  145.      0x0020, 0x0010, 0x0009, 0x0000, 0x0000},
  146.     {(int *)(alstop), (int *)(image_data), (char *)(p_to_nul), 0x0100, 0x0000,
  147.      0x0000, 0x0000, 0x0000, 0x0020, 0x0020,
  148.      0x0010, 0x000B, 0x0000, 0x0000},
  149.     {(int *)(dexclam), (int *)(image_data), (char *)(p_to_nul), 0x0100, 0x0000,
  150.      0x0000, 0x0000, 0x0000, 0x0020,
  151.      0x0020, 0x0020, 0x0020, 0x0000, 0x0000},
  152.     {(int *)(dquest), (int *)(image_data), (char *)(p_to_nul), 0x0100, 0x0000,
  153.      0x0000, 0x0000, 0x0000, 0x0020,
  154.      0x0020, 0x0020, 0x0020, 0x0000, 0x0000},
  155.     {(int *)(d_x), (int *)(image_data), (char *)(p_to_nul), 0x0100, 0x0000, 0x0000,
  156.      0x0000, 0x0000, 0x0020, 0x0020, 0x0020,
  157.      0x0020, 0x0000, 0x0000}
  158. };
  159.  
  160. #define NUM_OBS 12
  161. #define ALHEAD   2   /* BOXTEXT in Tree MYALERT */
  162. #define ALTXT1   4   /* TEXT in Tree MYALERT */
  163. #define ALTXT2   5   /* TEXT in Tree MYALERT */
  164. #define ALTXT3   6   /* TEXT in Tree MYALERT */
  165. #define ALTXT4   7   /* TEXT in Tree MYALERT */
  166. #define ALTXT5   8   /* TEXT in Tree MYALERT */
  167. #define ALICON   9   /* ICON in Tree MYALERT */
  168. #define ALBTN1   10  /* BOXTEXT in Tree MYALERT */
  169. #define ALBTDEF  11  /* BOXTEXT in Tree MYALERT */
  170. #define ALBTN2   12  /* BOXTEXT in Tree MYALERT */
  171. ICONBLK    *ALEXCLAM = { &ICONZ[0] };
  172. ICONBLK    *ALQUEST = { &ICONZ[1] };
  173. ICONBLK    *ALSTOP = { &ICONZ[2] };
  174. ICONBLK    *DEXCLAM = { &ICONZ[3] };
  175. ICONBLK    *DQUEST = { &ICONZ[4] };
  176. ICONBLK    *D_X = { &ICONZ[5] };
  177.  
  178. /*
  179.  *    Initialize MYALERT box stuff
  180.  *
  181.  *    This routine is to be called only at WInit time.  Any other time
  182.  *    after which will cause memory problems.
  183.  */
  184. GLOBAL void WInitAlert()
  185. {
  186.     RFix_ObjectPos(MYALERT);
  187.     fix_object(MYALERT, TRUE);
  188. }
  189.  
  190. GLOBAL int WFormCustAlert(int icn, char *text1, char *at1, char *at2, char *at3, char *at4, char *at5,
  191.                     char *bt1, char *bt2, char *bt3)
  192. {
  193.     int ex;
  194.     register OBJECT *al = MYALERT;
  195.  
  196.     if (al[ALBTN1].ob_flags & HIDETREE)
  197.         al[ALBTN1].ob_flags &= ~HIDETREE;
  198.  
  199.     if (al[ALBTDEF].ob_flags & HIDETREE)
  200.         al[ALBTDEF].ob_flags &= ~HIDETREE;
  201.  
  202.     if (al[ALBTN2].ob_flags & HIDETREE)
  203.         al[ALBTN2].ob_flags &= ~HIDETREE;
  204.  
  205.     switch (icn) {
  206.         case 1:    al[ALICON].ob_spec.iconblk = ALEXCLAM;
  207.                 break;
  208.  
  209.         case 2:    al[ALICON].ob_spec.iconblk = ALQUEST;
  210.                 break;
  211.  
  212.         case 3:    al[ALICON].ob_spec.iconblk = ALSTOP;
  213.                 break;
  214.  
  215.         case 4:    al[ALICON].ob_spec.iconblk = DEXCLAM;
  216.                 break;
  217.  
  218.         case 5:    al[ALICON].ob_spec.iconblk = DQUEST;
  219.                 break;
  220.  
  221.         case 6:    al[ALICON].ob_spec.iconblk = D_X;
  222.                 break;
  223.  
  224.         default:al[ALICON].ob_spec.iconblk = ALSTOP;
  225.                 break;
  226.     }
  227.  
  228.     if (strlen(bt1) <= 1) al[ALBTN1].ob_flags |= HIDETREE;
  229.     if (strlen(bt2) <= 1) al[ALBTDEF].ob_flags |= HIDETREE;
  230.     if (strlen(bt3) <= 1) al[ALBTN2].ob_flags |= HIDETREE;
  231.  
  232.     ChangeObjectText(al, ALHEAD, text1, 0, TE_CNTR);
  233.     ChangeObjectText(al, ALTXT1, at1, 0, TE_LEFT);
  234.     ChangeObjectText(al, ALTXT2, at2, 0, TE_LEFT);
  235.     ChangeObjectText(al, ALTXT3, at3, 0, TE_LEFT);
  236.     ChangeObjectText(al, ALTXT4, at4, 0, TE_LEFT);
  237.     ChangeObjectText(al, ALTXT5, at5, 0, TE_LEFT);
  238.     ChangeObjectText(al, ALBTN1, bt1, 0, TE_CNTR);
  239.     ChangeObjectText(al, ALBTDEF, bt2, 0, TE_CNTR);
  240.     ChangeObjectText(al, ALBTN2, bt3, 0, TE_CNTR);
  241.  
  242.     showdialog(al);
  243.     ex = dodialog(VDIhandle, al, FALSE, FALSE);
  244.     enddialog(al);
  245.  
  246.     if (ex == ALBTN1) return(1);
  247.     if (ex == ALBTDEF) return(2);
  248.     if (ex == ALBTN2) return(3);
  249.  
  250.     return(0);
  251. }